package com.webchat.pgc.service.mall;

import com.google.common.cache.Cache;
import com.webchat.common.enums.messagequeue.MessageBroadChannelEnum;
import com.webchat.common.service.localcache.AbstractLocalCacheService;
import com.webchat.pgc.constants.LocalCacheConstants;

import java.lang.reflect.Field;


public abstract class AbstractPgcLocalCacheService<K> extends AbstractLocalCacheService<K> {


    @Override
    protected MessageBroadChannelEnum getChannel() {

        return MessageBroadChannelEnum.QUEUE_REFRESH_PGC_LOCAL_CACHE;
    }

    @Override
    public Cache<K, Object> getCache(String cacheObjectName) {
        try {
            Field field = LocalCacheConstants.class.getDeclaredField(cacheObjectName);
            return (Cache<K, Object>) field.get(null);
        } catch (Exception e) {
            return null;
        }
    }
}
